<?php get_header(); ?>
	<div class="cate-banner">
		<img src="<?php bloginfo("template_url"); ?>/images/cate-banner.png" />
		<div class="row">
			<h1><?php post_type_archive_title(); ?></h1>
			<?php zonthemes_breadcrumbs(); ?>
		</div><!---end .row-->
		<div class="clear"></div>
	</div><!--end .cate-banner-->
	<div id="container" class="no-home-bg">
		<div class="row">
		<div class="content single-property">
			<?php $current_link = 'http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ?> 
			<?php if( !isset($_COOKIE["grid_list"]) ) { ?> <script type="text/javascript"> createCookie('grid_list','grid-layout',1); </script> <?php } ?>
			<?php if( !isset($_COOKIE["sort_by"]) ) { ?> <script type="text/javascript"> createCookie('sort_by','date',1); </script> <?php } ?>
			<?php if( !isset($_COOKIE["order_by"]) ) { ?> <script type="text/javascript"> createCookie('order_by','DESC',1); </script> <?php } ?>
			<div id="cate-page" <?php if(isset($_COOKIE["grid_list"])){echo 'class="'.$_COOKIE["grid_list"].'"';} ?>>
				<div class="cate-before">
					<div class="sort-by">
						<label>Order:</label>
						<select>
							<option <?php if(isset($_COOKIE['order_by']) AND $_COOKIE['order_by'] == 'DESC'){echo 'selected';} ?> value="DESC" onclick="createCookie('order_by','DESC',1); window.location='<?php echo  $current_link; ?>';" >DESC</option>
							<option <?php if(isset($_COOKIE['order_by']) AND $_COOKIE['order_by'] == 'ASC'){echo 'selected';} ?> value="ASC" onclick="createCookie('order_by','ASC',1); window.location='<?php echo  $current_link; ?>';" >ASC</option>
						</select>
						<label>Sort by:</label>
						<select>
							<option <?php if(isset($_COOKIE['sort_by']) AND $_COOKIE['sort_by'] == 'date'){echo 'selected';} ?> value="date" onclick="createCookie('sort_by','date',1); window.location='<?php echo  $current_link; ?>';" >Date</option>
							<option <?php if(isset($_COOKIE['sort_by']) AND $_COOKIE['sort_by'] == 'title'){echo 'selected';} ?> value="title" onclick="createCookie('sort_by','title',1); window.location='<?php echo  $current_link; ?>';" >Name</option>
							<option <?php if(isset($_COOKIE['sort_by']) AND $_COOKIE['sort_by'] == 'zon_price'){echo 'selected';} ?> value="zon_price" onclick="createCookie('sort_by','zon_price',1); window.location='<?php echo  $current_link; ?>';" >Price</option>
							<option <?php if(isset($_COOKIE['sort_by']) AND $_COOKIE['sort_by'] == 'zon_bedroom'){echo 'selected';} ?> value="zon_bedroom" onclick="createCookie('sort_by','zon_bedroom',1); window.location='<?php echo  $current_link; ?>';" >Bedroom</option>
							<option <?php if(isset($_COOKIE['sort_by']) AND $_COOKIE['sort_by'] == 'zon_tolet'){echo 'selected';} ?> value="zon_tolet" onclick="createCookie('sort_by','zon_tolet',1); window.location='<?php echo  $current_link; ?>';" >Bathroom</option>
						</select>
					</div><!--end .sort-by-->
					<div class="grid-list">
						<a href="#" onclick="createCookie('grid_list','list-layout',1); window.location='<?php echo  $current_link; ?>';" class="list <?php if(isset($_COOKIE['grid_list']) && $_COOKIE['grid_list'] == 'list-layout'){echo 'list-active';} ?>" data-view="list-layout">List</a>
						<a href="#" onclick="createCookie('grid_list','grid-layout',1); window.location='<?php echo  $current_link; ?>';" class="grid <?php if(isset($_COOKIE['grid_list']) && $_COOKIE['grid_list'] == 'grid-layout'){echo 'grid-active';} ?>" data-view="grid-layout">Grid</a>
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div><!--end .cate-before-->
				<ul class="pro-list">
					<?php
					$order_by = $_COOKIE['order_by'];
					$sort_by = $_COOKIE['sort_by'];
					if($sort_by == 'date' || $sort_by == 'title'){
						query_posts(
	                        array_merge(
	                            $wp_query->query,
	                            array(
	                                'orderby' => $sort_by,
	                                'order' => $order_by,
	                                'meta_key' => ''
	                            )
	                        )
	                    );
					}else{
						query_posts(
	                        array_merge(
	                            $wp_query->query,
	                            array(
	                                'orderby' => 'meta_value',
	                                'order' => $order_by,
	                                'meta_key' => $sort_by
	                            )
	                        )
	                    );
					}
                    ?>
					<?php if(have_posts()) while(have_posts()) : the_post(); ?>
						<li>
							<div class="list-img">
								<span class="list-new">New</span>
								<a href="<?php the_permalink(); ?>" class="view">View</a>
								<a href="<?php the_permalink(); ?>">
									<img class="pro-img" src="<?php echo zon_get_thumbnail("medium"); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" />
								</a>
							</div>
							<p class="pro-list-title">
								<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
							</p>
							<p class="pro-list-add">NY, New York, 10022</p>
							<p class="pro-list-desc"><?php echo get_the_excerpt(); ?></p>
							<p class="pro-list-price"><?php if(zon_meta("zon_lease") ==  "sale"){echo "Sale : ";}else{echo "Rent : ";} ?> <span><?php echo zon_meta("zon_price"); ?></span></p>
							<div class="pro-list-info">
								<span class="pro-list-area"><?php echo zon_meta("zon_area"); ?> sqft</span>
								<ul>
									<li class="pro-list-toilet"><?php echo zon_meta("zon_tolet"); ?></li>
									<li class="pro-list-bedroom"><?php echo zon_meta("zon_bedroom"); ?></li>
								</ul>
								<div class="clear"></div>
							</div>
							<div class="clear"></div>
						</li>
					<?php endwhile; ?>
					<div class="clear"></div>
				</ul>
				<div class="cate-after">
					<?php zonthemes_pagenavi(); ?>
					<div class="clear"></div>
				</div><!--end .cate-after-->
			</div>
		</div><!--end #content-->
		<?php get_sidebar(); ?>
		<div class="clear"></div>
		</div><!--end .row-->
	</div><!--end #container-->
<?php get_footer(); ?>